import Test.HUnit
import Helper
import Requests
import System.FilePath ((</>))
import Util


assertEq :: (Eq a, Show a) => a -> a -> Assertion 
assertEq = assertEqual ""

tests = [
   ("dos2unix converts dos line endings to unix style", do
        assertEq "ble\nbla\n" $ dos2unix "ble\r\nbla\r\n")

   , ("escapeUrl space", do
        let actual = escapeUrl "format c" 
        let expected = "format%20c"
        assertEq expected actual )
   
   , ("escapeUrl other chars", do
        let actual = escapeUrl "$&+,/:;=?@\"<>#%"
        let expected = "%24%26%2b%2c%2f%3a%3b%3d%3f%40%22%3c%3e%23%25"
        assertEq expected actual )

   , ("join", do
        assertEq "1;2;3" (join ";" ["1", "2", "3"]))

   , ("join empty list", do
        assertEq "" (join ";" ([] :: [String])))

   , ("join one element", do
        assertEq "foo" (join ";" ["foo"]))
   ]

suite = TestList $ map (\(l, tc) -> TestLabel l (TestCase tc)) tests

main = runTestTT suite
